package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.DaoEcologyPointsApplyExchangeRecords;
import com.sc.nft.entity.vo.PointsApplyExchangeRecordsPageVO;
import com.sc.nft.enums.PointsExchangeCollectionConsumeTypeEnum;
import com.sc.nft.enums.PointsExchangeCollectionStatusEnum;
import com.sc.nft.mapper.DaoEcologyPointsApplyExchangeRecordsMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.Date;

@Slf4j
@Repository
public class DaoEcologyPointsApplyExchangeRecordsDao extends ServiceImpl<DaoEcologyPointsApplyExchangeRecordsMapper, DaoEcologyPointsApplyExchangeRecords> {

    public IPage<PointsApplyExchangeRecordsPageVO> getPage(Long daoId, PointsExchangeCollectionStatusEnum applyStatus, Long collectionId, Date startTime, Date endTime, Page mp, PointsExchangeCollectionConsumeTypeEnum consumeType) {
        return baseMapper.getPage(daoId,applyStatus,collectionId,startTime,endTime,mp,consumeType);
    }

    public boolean updateStatus(Long id,PointsExchangeCollectionStatusEnum pointsExchangeCollectionStatusEnum, String remark) {
        LambdaUpdateWrapper<DaoEcologyPointsApplyExchangeRecords> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(DaoEcologyPointsApplyExchangeRecords::getId,id);
        updateWrapper.set(DaoEcologyPointsApplyExchangeRecords::getApplyStatus,pointsExchangeCollectionStatusEnum);
        updateWrapper.set(DaoEcologyPointsApplyExchangeRecords::getRemark,remark);
        return update(updateWrapper);
    }
}